# Balzebub

A C++ lightweight modular general-purpose library for low-level interfacing with system APIs in a cross-platform way.
It supports simplified file reading and writing with binary support, ELF file 
parsing, memory features like writing and reading from process memory, keyboard input support, colored shell output and networking with TCP and UDP support.

## Project structure

Balzebub is divided in many distinct modules providing different features.
You can pick the ones you need and compile your programs only with them.
These are the supported modules:

- **bzbutil**: Main module providing system and compiler detection and system exceptions.

- **bzbstring**: Simple header-only module exposing common string manipulation functions, including a Base64 encoder and decoder.

- **bzbio**: Header-only module which provides easy terminal output including colored output and other minor features.

- **bzbfile**: File reading and writing using strings or data buffers in binary. Supports other file operations such as checking a file's existence or listing a folder's files. There are also an **ELF file parser** and an **INI file parser**.

- **bzbshell**: Module which provides shell-related facilities like executing commands or setting the current working directory.

- **bzbterm**: Module exposing functions and structures to enhance terminal usage using escape codes.

- **bzbcrypto**: **Work-in-progress** module providing cryptographic functions including SHA hashing and secure random numbers. (needs **libgcrypt** and **libgpg-error** to function, define BZBCRYPTO_UNSTABLE to enable support).

- **bzbtime**: Small module providing date handling structures.

- **bzbnet**: **Work-in-progress** module providing socket connections trough TCP and UDP and an **HTTP parser**. TLS connections are being implemented by using **GnuTLS**.

- **bzbmem**: Module providing access and manipulation to virtual memory, with utility functions to handle PIDs.

- **bzbinput**:  System-specific module exposing functions to handle console input.

You may use specific modules by compiling their specific source file (e.g. _bzbcrypto.cpp_ to use **bzbcrypto**).
Modules have dependencies which are listed in their source file in _src/_, although most modules rely only on **bzbutil**.

## Dependencies

You need to link **libgcrypt** and **libpgp-error** to fully use **bzbcrypto**.
You need to link **GnuTLS** to use TLS connections in **bzbnet** (by default it's disabled)

On Windows you need to link against **WinSock 2** if you want to use **bzbnet** functionalities.
You can simply add
>	-lws2_32

to the compiler's arguments (for example in the Makefile in the CXXFLAGS).

## How to build

Run **configure.sh** if you're on Linux:
>	./configure.sh

Create a folder named _bin/_ if you're on Windows:
>	mkdir bin

Now you are ready to compile the library!

Build all at once:
>	make

Build the shared library:
>	make shared

Build the example program:
>	make example

Build the example program for 32-bit systems:
>	make example32

Build the tool programs:
>	make tools

Build the test programs:
>	make tests

Run all tests:
>	make run_tests

Install the library, the tools and the headers:
>	make install

The files will be installed to the /usr/local/bin/ and /usr/local/lib/ folders,
the headers to /usr/local/include/bzb/

After this, you can test if the library is correctly installed by running the program:
>	balzebub

On Windows, having MinGW or MinGW-w64 should be enough to use the same commands.

## Macros

You may define **BZB_SLIM** to disable the ELF and INI parsers and terminal animations (it needs functionality from **bzbmem** which you may not want to compile).

You may define **BZBCRYPTO_UNSTABLE** to use TLS functionalities in **bzbnet** and cryptographic functions in **bzbcrypto** which are still unstable.
